<!DOCTYPE html>
<#assign f = JspTaglibs["http://www.casic304.cn/f"] />
<#assign dicSelect = JspTaglibs["http://www.casic304.cn/dicSelect"]/>
<#assign SourceDept = JspTaglibs["http://www.casic304.cn/SourceDept"]/>
<head>
    <meta charset="utf-8">
    <title>飞行试验管理信息列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${ctx}/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="${ctx}/qbdmsStatic/iconfont/iconfont.css"/>
    <link rel="stylesheet" href="${ctx}/qbdmsStatic/style/qbdms.css">
    <script type="text/javascript">
        var __ctx = "${ctx}";
    </script>
</head>
<body class="listBody">
<div class="qbdms-list">
    <div class="layui-table-view-body">
        <table id="wQbdFlightTestTable" lay-filter="wQbdFlightTestTable"></table>
    </div>
</div>
<!-- 列表头部工具栏 -->
<script type="text/html" id="wQbdFlightTestHeaderToolsBar">
    <div class="ccpui-enterSel">
        <div class="layui-btn-container">
            <@f.a alias="fxsyxxgl_xzan3" event="add" css="layui-btn layui-btn-sm fillBtn">
                <span>新增</span>
            </@f.a>
            <@f.a alias="fxsyxxgl_scan3" event="delete" css="layui-btn layui-btn-sm">
                <span>删除</span>
            </@f.a>
            <a class="layui-btn layui-btn-sm" lay-event="export">
                <span>导出</span>
            </a>
            <@f.a alias="fxsyxxgl_dran2,fxsyxxgl_dran3" event="import" css="layui-btn layui-btn-sm">
                <span>导入</span>
            </@f.a>
            <@f.a alias="fxsyxxgl_sban2,fxsyxxgl_sban3" event="report" css="layui-btn layui-btn-sm">
                <span>上报</span>
            </@f.a>
            <a class="layui-btn layui-btn-sm" lay-event="listStyle">
                <span>配置列</span>
            </a>
        </div>
        <form class="layui-form" action="" lay-filter="wQbdFlightTestQueryForm">
            <div class="layui-form-body selch">
                <div class="table-top-filter layui-row">
                    <@SourceDept.dept css="layui-input filter-value"/>
                    <div class="qbdms-listForm">
                        <label class="layui-form-label">试验名称</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input filter-value" name="Q_fTestname_SL" placeholder="请输入"/>
                        </div>
                    </div>
                    <div class="qbdms-listForm">
                        <label class="layui-form-label">型号代号</label>
                        <div class="layui-input-block">
                            <select name="Q_fModelsymbol_S" class="layui-input filter-value" lay-filter="xh" lay-verify="required" lay-search=""></select>
                        </div>
                    </div>
                    <div class="qbdms-listForm">
                        <label class="layui-form-label">型号类型</label>
                        <div class="layui-input-block">
                            <@dicSelect.dic name="Q_fModeltype_S" css="layui-input filter-value" nodeKey="xhlx" />
                        </div>
                    </div>
                    <div class="qbdms-listForm">
                        <label class="layui-form-label">型号研制阶段</label>
                        <div class="layui-input-block">
                            <@dicSelect.dic name="Q_fModeldevelopphase_S" css="layui-input filter-value" nodeKey="xhyzjd" />
                        </div>
                    </div>
                    <div class="qbdms-listForm">
                        <label class="layui-form-label">飞行结果</label>
                        <div class="layui-input-block">
                            <@dicSelect.dic name="Q_fFlightresult_S" css="layui-input filter-value" nodeKey="fxjg" />
                        </div>
                    </div>
                    <div class="qbdms-listForm">
                        <label class="layui-form-label">发射开始日期</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input start_time2 filter-value" name="Q_beginFLaunchdate_DL" placeholder="请输入" readonly/>
                        </div>
                    </div>
                    <div class="qbdms-listForm">
                        <label class="layui-form-label">发射结束日期</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input end_time2 filter-value" name="Q_endFLaunchdate_DE" placeholder="请输入" readonly/>
                        </div>
                    </div>
                </div>
                <div class="selchBtn">
                    <a class="layui-btn layui-btn-sm fillBtn" lay-event="query">
                        <span>查询</span>
                    </a>
                    <div class="layui-btn-group">
                        <button type="button" class="layui-btn layui-btn-sm" lay-event="clears" style="width: 28px;font-size: 12px;padding: 0">
                            <i class="iconfont data-iconcommon_refresh"></i>
                        </button>
                        <button type="button" class="layui-btn layui-btn-sm screenParent" lay-event="screen" style="width: 28px;font-size: 12px;padding: 0">
                            <i class="iconfont data-iconcommon_downarrow screen"></i>
                        </button>
                    </div>
                </div>
            </div>
        </form>
    </div>
</script>
<!-- 右侧工具栏 -->
<script type="text/html" id="wQbdFlightTestRightToolsBar">
    {{# if('${currentUserId}'==d.createBy && d.allowEdit){ }}
    <@f.a alias="fxsyxxgl_xgan3" event="edit" css="RightBtn">编辑</@f.a>
    {{#  } }}
    <a class=" RightBtn" lay-event="particulars">详情</a>
    {{# if('${currentUserId}'==d.createBy && d.allowDel){ }}
    <@f.a alias="fxsyxxgl_scan3" event="del" css="RightBtn">删除</@f.a>
    {{#  } }}
</script>
<script src="${ctx}/qbdmsStatic/public/configFile.js"></script>
<script src="${ctx}/layui/layui.js"></script>
<script>
    //一般直接写在一个js文件中
    layui.config({
        base: serverPath.qbdmsPath + staticPath.qbdmsPath //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table', 'form', 'common', 'publicMethods', 'jquery', 'layer','propsHandle'], function () {
        var table = layui.table;
        var form = layui.form;
        var common = layui.common;
        var publicMethods = layui.publicMethods;
        var $ = layui.jquery;
        var layer = layui.layer;
        var propsHandle = layui.propsHandle;
        var defProps = {
                //viewMould: 'form/formDef/view/formDesign/moulds/', // 组件模块 存放文件 *****
                viewMould: 'moulds/', // 组件模块 存放文件 *****
                selectorBtn: '.selectorBtn'
            },
            temQuery = new propsHandle();  // 实例化模板功能部分
        temQuery.initTem({
            selectorBtn: defProps.selectorBtn,
            selectorTemPath: setter.views + defProps.viewMould
        });
        common.tableSort('wQbdFlightTestTable');

        var tableH = publicMethods.tabHeight();
        var currentSystemLevel = "${currentSystemLevel}";
        var orderCols = [{type: 'checkbox', fixed: 'left'},{field: 'sn', type: 'numbers', title: '序号', fixed: 'left'}];
        var fillDeptCols = [];
        if ("GROUPLEVEL" === currentSystemLevel) {
            fillDeptCols = [{field: 'filldeptHospital', title: '数据来源单位', sort: false, sortname: 'filldepthospital',minWidth:'150'}];
        } else if ("HOSPITALLEVEL" === currentSystemLevel) {
            fillDeptCols = [{field: 'filldept', title: '数据来源单位', sort: false, sortname: 'filldept',minWidth:'150'}];
        } else if ("PLANTLEVEL" === currentSystemLevel) {
            fillDeptCols = [{field: 'filldept', title: '数据来源单位', sort: false, sortname: 'filldept',minWidth:'150'}];
        }
        var commonCols= [ //表头
             {field: 'fTestname', title: '试验名称', sort: false, sortname: 'f_testname',minWidth:'100'}
            , {
            field: 'fLaunchdate', title: '发射日期', sort: false, sortname: 'f_launchdate',minWidth:'110', templet: function (d) {
                return publicMethods.timeData(d.fLaunchdate);
            }
        }
            , {field: 'fModelsymbol', title: '型号代号', sort: false, sortname: 'f_modelsymbol',minWidth:'100'}
            , {field: 'fModeltype', title: '型号类型', sort: false, sortname: 'f_modeltype',minWidth:'100'}
            , {field: 'fModeldevelopphase', title: '研制阶段', sort: false, sortname: 'f_modeldevelopphase',minWidth:'100'}
            , {field: 'fFlightresult', title: '飞行结果', sort: false, sortname: 'f_flightresult',minWidth:'100'}
            , {field: 'fTestplace', title: '试验地点', sort: false, sortname: 'f_testplace',minWidth:'100'}
            , {field: 'fTeststatus', title: '试验情况', sort: false, sortname: 'f_teststatus',minWidth:'100'}
            , {field: 'secret', title: '密级',sort:true, sortname: 'secret',minWidth:'80'}
            , {field: 'fillman', title: '填写人', sort: false, sortname: 'fillman', hide: true,minWidth:'100'}
            , {field: 'filldate', title: '填写时间', sort: false, sortname: 'filldate', hide: true,minWidth:'100'}
            , {field: 'fEntrysign', title: '进场标识', sort: false, sortname: 'f_entrysign', hide: true,minWidth:'100'}
            , {field: 'fFilingnumber', title: '入档编号', sort: false, sortname: 'f_filingnumber', hide: true,minWidth:'100'}
            , {field: 'fModelnmae', title: '型号名称', sort: false, sortname: 'f_modelnmae', hide: true,minWidth:'100'}
            , {field: 'fModelbatchno', title: '型号批次', sort: false, sortname: 'f_modelbatchno', hide: true,minWidth:'100'}
            , {field: 'fTechnicalstatus', title: '技术状态', sort: false, sortname: 'f_technicalstatus', hide: true,minWidth:'100'}
            , {field: 'fPopulationunit', title: '总体单位', sort: false, sortname: 'f_populationunit', hide: true,minWidth:'100'}
            , {field: 'fGeneralunit', title: '总装单位', sort: false, sortname: 'f_generalunit', hide: true,minWidth:'100'}
            , {field: 'fTestcode', title: '试验代号', sort: false, sortname: 'f_testcode', hide: true,minWidth:'100'}
            , {field: 'fTestphase', title: '试验性质', sort: false, sortname: 'f_testphase', hide: true,minWidth:'100'}
            , {field: 'fMissilenumber', title: '导弹编号', sort: false, sortname: 'f_missilenumber', hide: true,minWidth:'100'}
            , {
            field: 'fTestdate', title: '试验日期', sort: false, sortname: 'f_testdate',minWidth:'100', templet: function (d) {
                return publicMethods.timeData(d.fTestdate);
            }
            , hide: true
        }
            , {field: 'fLaunchstatus', title: '发射情况', sort: false, sortname: 'f_launchstatus', hide: true,minWidth:'100'}
            , {field: 'fFlighttestproblems', title: '飞行试验问题数', sort: false, sortname: 'f_flighttestproblems', hide: true,minWidth:'180'}
            , {field: 'fExclusionbasis', title: '剔除依据', sort: false, sortname: 'f_exclusionbasis', hide: true,minWidth:'100'}
            , {field: 'fFailurereason', title: '失利原因', sort: false, sortname: 'f_failurereason', hide: true,minWidth:'100'}]
        var reportStatusCols =[];
        if ("GROUPLEVEL" !== currentSystemLevel) {
            reportStatusCols = [{
                field: 'reportStatusStr', title: '状态', sort: false, sortname: 'REPORT_STATUS', hide: false,minWidth:'200', templet: function (d) {
                    return common.stateType(d);
                }
            }];
        }
        var manageCols = [{
            fixed: 'right',
            title: '管理',
            minWidth:200,
            toolbar: '#wQbdFlightTestRightToolsBar'
        }];
        var totalCols = [];
        totalCols = totalCols.concat(orderCols).concat(fillDeptCols).concat(commonCols).concat(reportStatusCols).concat(manageCols);;

        var cols = '${cols}';
        //第一个实例
        window.tableInstace = function(tcols){
            if(tcols){
                cols = tcols;
            }
            if(cols){
                cols = JSON.parse(cols,function(k,v){
                    if(v.indexOf && v.indexOf('function') > -1){
                        return eval("(function(){return "+v+" })()")
                    }
                    return v;
                })
            }
            window.tableInstace.initCols = totalCols;
            window.tableInstace.tRender = table.render({
                elem: '#wQbdFlightTestTable'
                , height: tableH
                , url: serverPath.qbdmsPath + '/qbdms/wQbdFlightTest/list'
                ,page: publicMethods.pageFun()
                , limit: 20
                ,defaultToolbar: ['']
                , toolbar: '#wQbdFlightTestHeaderToolsBar'
                , method: 'post'
                , autoSort: false //是否排序
                , cols: [cols?cols:window.tableInstace.initCols], done: function () {
                    table.resize("wQbdFlightTestTable");
                    common.tableSelectCon('.ccpui-enterSel .layui-form input', 'a[lay-event=query]', '.ccpui-enterSel');
                }
                ,parseData: function(res){ //res 即为原始返回的数据
                    common.parseDataList(res,['fModeltype','fTestplace','fTeststatus']);
                    return {
                        "code": res.code, //解析接口状态
                        "msg": res.msg, //解析提示文本
                        "count": res.count, //解析数据长度
                        "data": res.data //解析数据列表
                    };
                }
            });
        }
        window.tableInstace(cols);
        //list页面初始化展开按钮tips展示（展开按钮类名）
        publicMethods.tipsAuto('.screen')
        //筛选条件初始化（页面表格的Id，是否初始化（true、false））
        common.initScreenTop('wQbdFlightTestTable',true);
        dateReflash();
        function dateReflash() {
            publicMethods.reflashDate({startName: '.start_time1', endName: '.end_time1'});
            publicMethods.reflashDate({startName: '.start_time2', endName: '.end_time2'});
            publicMethods.reflashDate({startName: '.start_time3', endName: '.end_time3'});
            publicMethods.reflashDate({startName: '.start_time4', endName: '.end_time4'});
        }

        function reflashQuery(isClear) {
            common.tableConditionRender("wQbdFlightTestTable", "wQbdFlightTestQueryForm", {where: {}}, isClear, false, 20);
            var xhdh = eval('${wQbdXhdhs}'); //型号代号
            var initXHDH = function(optionObj, item){
                optionObj.text = item.fModelcode;
                optionObj.value = item.fModelcode;
                optionObj.setAttribute("xhmc", item.fModelname);
            };
            common.initDicData("Q_fModelsymbol_S", xhdh, "", initXHDH);
        }

        //监听排序事件
        table.on('sort(wQbdFlightTestTable)', function(){
            reflashQuery(false);
        });

        table.on('toolbar(wQbdFlightTestTable)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id);
            var data = checkStatus.data;
            var _this = this;
            var layerH=publicMethods.layHeight('.listBody');
            switch (obj.event) {
                case 'add':
                    window.location.href = serverPath.qbdmsPath + "/qbdms/wQbdFlightTest/view/add";
                    break;
                case 'delete':
                    var array = "";
                    for (var i = 0; i < data.length; i++) {
                        array += data[i].id + ",";
                    }
                    delFun(data, array);
                    break;
                case 'export':
                    if (data.length == 0) {
                        layer.confirm(publicMethods.confirmStyle('还没有选择，是否导出全部?'),{title: false,skin: 'confirm-class'},
                         function (index) {
                            layer.close(index);
                            var url = serverPath.qbdmsPath + '/qbdms/wQbdFlightTest/exportData';
                            var param = "";
                            $("form[lay-filter='wQbdFlightTestQueryForm']").find(".filter-value").each(function (i, value) {
                                param += "&" + this.name + "=" + this.value
                            });
                            open(url, param);
                        });
                    } else {
                        layer.confirm(publicMethods.confirmStyle('确定导出吗?'),{title: false,skin: 'confirm-class'},
                            function (index) {
                            layer.close(index);
                            var ids = [];
                            for (var i = 0; i < data.length; i++) {
                                ids.push(data[i].id);
                            }
                            var url = serverPath.qbdmsPath + '/qbdms/wQbdFlightTest/exportData';
                            open(url, "&id=" + ids);
                        });
                    }
                    break;
                case "import":
                    common.importInit('wQbdFlightTestTable',"/qbdms/wQbdFlightTest/importData",true,"/importTemplates/飞行试验信息.xlsx");
                    dateReflash();
                    break;
                case "query":
                    reflashQuery(false);
                    dateReflash();
                    break;
                case "clears":
                    reflashQuery(true);
                    dateReflash();
                    break;
                case "screen":
                    common.initScreenTop('wQbdFlightTestTable');
                    dateReflash();
                    form.render();
                    break;
                case "listStyle":
                    layer.open({
                        type: 2,
                        area: ['80%', layerH],
                        skin: 'qbdms-layerFormBtn',
                        title: ['新增列表样式', 'font-size:14px;'],
                        content: __ctx + '/qbdms/wCustomColumns/view/list',
                        success:function (layero, index) {
                            publicMethods.tipsAuto(layero.find('.layui-layer-setwin'),'点击这里关闭弹框哦',2000)
                        }
                    });
                    break;
                case "report":
                    var array = "";
                    for (var i = 0; i < data.length; i++) {
                        array += data[i].id + ",";
                    }
                    //业务表名,勾选数据主键,流程key,table标签lay-filter属性值,form标签lay-filter属性值,是否允许重复上报,页面所在包名,流程定义id
                    common.report("w_qbd_flight_test",array,"plantToHospital","wQbdFlightTestTable","wQbdFlightTestQueryForm",false,"wQbdFlightTest","plantToHospital:1:72d05d40362249118c5453aa60c6da90");
                    dateReflash();
                    break;
            }
            ;
        });

        table.on('tool(wQbdFlightTestTable)', function (obj) {
            var data = obj.data, //获得当前行数据
                layEvent = obj.event; //获得 lay-event 对应的值
            switch (layEvent) {
                case "edit":
                    window.location.href = serverPath.qbdmsPath + '/qbdms/wQbdFlightTest/view/add?id=' + data.id
                    break;
                case "particulars":
                    window.location.href = serverPath.qbdmsPath + '/qbdms/wQbdFlightTest/view/particulars?id=' + data.id;
                    break;
                case "del":
                    delFun(data, data.id);
                    // form.render();
                    break;
            }
        });

        function delFun(data, id) {
            if (data.length === 0) {
                layer.confirm(publicMethods.confirmStyle("请先选择一行数据!"),{title: false,skin: 'confirm-class'});
            } else {
                layer.confirm(publicMethods.confirmStyle('确定删除当前数据吗?'),{title: false,skin: 'confirm-class'},function (index) {
                    layer.close(index);
                    $.ajax({
                        url: serverPath.qbdmsPath + "/qbdms/wQbdFlightTest/del",
                        type: "post",
                        data: {id: id},
                        dataType: 'json',
                        success: function (data) {
                            layer.confirm(publicMethods.confirmStyle(data.msg),{title: false,skin: 'confirm-class'});
                            //执行重载
                            reflashQuery(true);
                            dateReflash();
                        },
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                            layer.confirm(publicMethods.confirmStyle(data.msg),{title: false,skin: 'confirm-class'});
                            //执行重载
                            reflashQuery(true);
                            dateReflash();
                        }
                    })
                })
            }

        }

        window.Initialization = function () {
            reflashQuery(false);
            dateReflash();
        };
        /*刷新时间控件*/
        dateReflash();
        common.tableSort("wQbdFlightTestTable");

        var xhdh = eval('${wQbdXhdhs}'); //型号代号
        var initXHDH = function(optionObj, item){
            optionObj.text = item.fModelcode;
            optionObj.value = item.fModelcode;
            optionObj.setAttribute("xhmc", item.fModelname);
        };
        common.initDicData("Q_fModelsymbol_S", xhdh, "", initXHDH);

        function open(url, param) {
            var curUrl = url;
            layer.open({
                type: 2,
                area: ['700px', '520px'],
                title: ['自定义导出', 'font-size:14px;'],
                content: serverPath.qbdmsPath + '/qbdms/wQbdFlightTest/view/export',
                btnAlign: 'c',
                skin: 'qbdms-layerFormBtn',
                btn: ['确定', '取消'],
                yes: function (index, layero) {
                    url = curUrl;
                    var iframeWin = window["layui-layer-iframe" + index];
                    var data = iframeWin.getData();
                    if (data) {
                        url = url + "?data=" + JSON.stringify(data) + param;
                        window.location.href = encodeURI(url)
                    }
                }
            });
        }
    });
</script>
</body>
</html>